package com.design_pattern._02_structure._05_facade;

/**
 * 创建厨师、洗碗工、服务员，可以使用单例
 */
public class Facade {

    private final Waiter waiter;
    private final Cook cook;
    private final DishWasher dishWasher;

    public Facade() {
        this.waiter = new Waiter();
        this.cook = new Cook();
        this.dishWasher = new DishWasher();
    }

    /**
     * 创建订单，工序繁杂，但是只暴露这一个接口
     */
    public void orderFood() {
        waiter.writeOrder();
        waiter.notifyCook();
        cook.prepareFood();
        cook.notifyWaiter();
        waiter.serveCustomer();
    }

    public void leave() {
        waiter.cleanUp();
        dishWasher.washDishes();
    }
}

class Cook {
    public void prepareFood() {
        System.out.println("厨师准备菜品");
    }

    public void notifyWaiter() {
        System.out.println("厨师通知服务员");
    }
}

class Waiter {

    public void writeOrder() {
        System.out.println("服务员写下顾客点的菜品");
    }

    public void notifyCook() {
        System.out.println("服务员通知厨师");
    }

    public void serveCustomer() {
        System.out.println("服务员为顾客端菜");
    }

    public void cleanUp() {
        System.out.println("服务员收拾餐桌");
    }
}

class DishWasher { // 洗碗工
    public void washDishes() {
        System.out.println("清洁员洗刷碗筷");
    }
}

